//
//  MHMessageListHeader.m
//  MiaoCircle
//
//  Created by 许正荣 on 2018/5/28.
//  Copyright © 2018年 acgera. All rights reserved.
//

#import "MHMessageListHeader.h"
#import "UIButton+ImageTitleSpacing.h"
#import "JSCustomBadge.h"
@import Foundation;

@implementation MHMessageListHeader

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)awakeFromNib
{
    [super awakeFromNib];
    CGFloat space = 15;
    [self.aboutMeButton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleTop
                                    imageTitleSpace:space];
    [self.notiyButton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleTop
                                        imageTitleSpace:space];
    [self.systemMessageButton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleTop
                                      imageTitleSpace:space];
    [self.collectionButton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleTop
                                              imageTitleSpace:space];
//    self.redDotImageView.hidden = YES;
    self.timeLable.hidden = YES;
//    self.redDotImageView.backgroundColor = [UIColor whiteColor];
    
//    self.redDotImageView = [[JSCustomBadge alloc] init];
    ImageTitleButton *btn = [[ImageTitleButton alloc] init];
    btn.imageSize = CGSizeZero;
    btn.margin = UIEdgeInsetsMake(0, 0, 0, 0);
    btn.padding = CGSizeZero;
     self.unReadBadge = btn;
    self.unReadBadge.backgroundColor = kRedColor;
    self.unReadBadge.layer.cornerRadius = 10;
    self.unReadBadge.layer.masksToBounds = YES;
    self.unReadBadge.titleLabel.font = kAppSmallTextFont;
    self.unReadBadge.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.unReadBadge.titleLabel.adjustsFontSizeToFitWidth = YES;
    [self.unReadBadge setTitleColor:kWhiteColor forState:UIControlStateNormal];
//    [self.unReadBadge addTarget:self action:@selector(onClickUnRead:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.unReadBadge];
    
}


-(void)layoutSubviews
{
    [super layoutSubviews];
    
//    [_unReadBadge sizeWith:CGSizeMake(24, 24)];
    
//    [_unReadBadge alignRight:_lastMsgTime];
//    [_unReadBadge alignVerticalCenterOf:_lastMsg];
    [self.unReadBadge mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.timeLable.mas_bottom).offset(3);
        make.right.equalTo(self).offset(-15);
        make.width.height.equalTo(@20);
    }];
}
@end
